package com.huitu.whht.base.core.api.wq.pas;

import com.huitu.api.rest.AbstractApiResource;
import com.huitu.commons.PageUtils;
import com.huitu.whht.api.core.common.response.ApiResultBuilder;
import com.huitu.whht.api.core.common.annotations.SzyCoreApiResource;
import com.huitu.whht.api.core.common.annotations.SzyCoreApiService;
import com.huitu.whht.api.core.common.response.StatusRespBuilder;

import com.huitu.whht.base.core.api.wq.pas.entities.WqPasA;
import com.huitu.whht.base.core.api.wq.pas.entities.WqPasAKey;
import com.huitu.whht.base.core.api.wq.pas.entities.WqPasAQo;
import com.huitu.whht.base.core.api.wq.pas.service.IWqPasAService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

/**
 * 说明: API,表名称: WQ_PAS_A <br/>
 * 日期: 2019-04-11
 * @author LiuCW
 */
@Component
@SzyCoreApiResource
@Path("wq/pas/a")
public class WqPasAResource extends AbstractApiResource {

    private static final Logger LOGGER = LoggerFactory.getLogger(WqPasAResource.class);

    private static final String UUID = "b563180a-2a27-4cfe-be22-ee407977f5fa";

    @Override
    public String getUUID() {
        return UUID;
    }

    @Autowired
    @SzyCoreApiService
    IWqPasAService wqPasAService;

    /**
     * @api {get} wq/pas/a/{itmid}/{stncd}/{wqg}/{smcl} [R][G]根据主键查询
     * @apiDescription [G]根据主键查询WQ_PAS_A()数据
     * @apiName (generate)select by primary key
     * @apiGroup WQ_PAS_A-
     * @apiVersion 1.0.0
     * @apiSampleRequest wq/pas/a/TP/e8c7392e8b984189a89ab594bb3d3e51/4/1
     * @apiParam   {String}         itmid              【必须】暂无注释
     * @apiParam   {String}         stncd              【必须】暂无注释
     * @apiParam   {String}         wqg                【必须】暂无注释
     * @apiParam   {Integer}        smcl               【必须】暂无注释
     * @apiSuccess {String}         itmid              暂无注释
     * @apiSuccess {Integer}        smcl               暂无注释
     * @apiSuccess {String}         stncd              暂无注释
     * @apiSuccess {String}         wqg                暂无注释
     * @apiSuccess {Double}         wqgulv             暂无注释
     * @apiSuccess {Double}         wqgllv             暂无注释
     * @apiSuccessExample 请求成功:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "itmid": "TP",
     * "smcl": 1,
     * "stncd": "e8c7392e8b984189a89ab594bb3d3e51",
     * "wqg": "4",
     * "wqgulv": 0.3,
     * "wqgllv": 0.2
     *  }
     * }
     * @apiUse exceptions
     */
    @GET
    @Path("{itmid}/{stncd}/{wqg}/{smcl}")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response selectByPrimaryKey(@PathParam("itmid") String itmid,@PathParam("stncd") String stncd,@PathParam("wqg") String wqg,@PathParam("smcl") Integer smcl) {
        WqPasAKey pk = new WqPasAKey();
        pk.setItmid(itmid);
        pk.setStncd(stncd);
        pk.setWqg(wqg);
        pk.setSmcl(smcl);
        LOGGER.info("根据主键查询 ,参数 pk:{}", pk);
        return Response.ok(ApiResultBuilder.create(this, wqPasAService.selectByPrimaryKey(pk))).build();
    }

    /**
     * @api {post} wq/pas/a/list [R][G]根据条件查询
     * @apiDescription [G]根据条件查询WQ_PAS_A()数据
     * @apiName (generate)select by filter
     * @apiGroup WQ_PAS_A-
     * @apiVersion 1.0.0
     * @apiSampleRequest wq/pas/a/list
     * @apiParam   {String}         itmid              暂无注释
     * @apiParam   {List(Integer)}  smclList           (数组)暂无注释
     * @apiParam   {String}         stncd              暂无注释
     * @apiParam   {List(String)}   wqgList            (数组)暂无注释
     * @apiParam   {Double}         wqgulvMin          (最小)暂无注释
     * @apiParam   {Double}         wqgulvMax          (最大)暂无注释
     * @apiParam   {Double}         wqgllvMin          (最小)暂无注释
     * @apiParam   {Double}         wqgllvMax          (最大)暂无注释
     * @apiSuccess {String}         itmid              暂无注释
     * @apiSuccess {Integer}        smcl               暂无注释
     * @apiSuccess {String}         stncd              暂无注释
     * @apiSuccess {String}         wqg                暂无注释
     * @apiSuccess {Double}         wqgulv             暂无注释
     * @apiSuccess {Double}         wqgllv             暂无注释
     * @apiSuccessExample 请求成功:
     * HTTP/1.1 200 OK
     * {
     * "result": [{
     * "itmid": "TP",
     * "smcl": 1,
     * "stncd": "e8c7392e8b984189a89ab594bb3d3e51",
     * "wqg": "4",
     * "wqgulv": 0.3,
     * "wqgllv": 0.2
     *  }]
     * }
     *
     * @apiSuccessExample 分页请求:
     * request header: Rang={max=50;size=50;field=TS DESC}
     * HTTP/1.1 200 OK
     * {
     * "result": [{
     * "itmid": "TP",
     * "smcl": 1,
     * "stncd": "e8c7392e8b984189a89ab594bb3d3e51",
     * "wqg": "4",
     * "wqgulv": 0.3,
     * "wqgllv": 0.2
     *  }],
     * "paging": {
     * "count": 3,
     * "total": 120,
     * "finale": false,
     * "index": 1
     * }
     * }
     * @apiUse header_rang
     * @apiUse exceptions
     */
    @POST
    @Path("list")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response selectList(WqPasAQo filter) {
        PageUtils.startPageFromRang();
        LOGGER.info("根据条件查询 ,参数 WqPasAQo:{}", filter);
        return Response.ok(ApiResultBuilder.create(this, wqPasAService.selectList(filter))).build();
    }

    /**
     * @api {put} wq/pas/a [C][G]新增数据
     * @apiPrivate
     * @apiDescription [G]新增WQ_PAS_A()数据
     * @apiName (generate)add data
     * @apiGroup WQ_PAS_A-
     * @apiVersion 1.0.0
     * @apiParam   {String}         itmid              【必须】暂无注释
     * @apiParam   {Integer}        smcl               【必须】暂无注释
     * @apiParam   {String}         stncd              【必须】暂无注释
     * @apiParam   {String}         wqg                【必须】暂无注释
     * @apiParam   {Double}         wqgulv             暂无注释
     * @apiParam   {Double}         wqgllv             暂无注释
     * @apiSuccess {Integer}        status             1:新增成功;0:新增失败.
     * @apiSuccess {String}         message            成功/失败消息内容
     * @apiSuccess {Object}         data               额外返回的数据,通常包含新增数据的主键值
     * @apiSampleRequest wq/pas/a
     * @apiSuccessExample 新增成功:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":1,
     * "message":"成功",
     * "data":{
     *   "itmid": "TP",
     *   "stncd": "e8c7392e8b984189a89ab594bb3d3e51",
     *   "wqg": "4",
     *   "smcl": 1
     *      }
     *   }
     * }
     @apiSuccessExample 新增失败:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":0,
     * "message":"失败",
     * "data":{
     *   "itmid": "TP",
     *   "stncd": "e8c7392e8b984189a89ab594bb3d3e51",
     *   "wqg": "4",
     *   "smcl": 1
     *      }
     *   }
     * }
     * @apiParamExample {json} 请求示例:
     * {
     * "itmid": "TP",
     * "smcl": 1,
     * "stncd": "e8c7392e8b984189a89ab594bb3d3e51",
     * "wqg": "4",
     * "wqgulv": 0.3,
     * "wqgllv": 0.2
     * }
     * @apiUse exceptions
     */
    @PUT
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response insert(WqPasA record) {
        LOGGER.info("新增 ,参数 WqPasA:{}", record);
        return Response.ok(ApiResultBuilder.create(this, StatusRespBuilder.insert(wqPasAService.insertSelective(record),record))).build();
    }

    /**
     * @api {post} wq/pas/a/insertBatch [C][G]批量新增数据
     * @apiPrivate
     * @apiDescription [G]批量新增WQ_PAS_A()数据
     * @apiName (generate)addBatch data
     * @apiGroup WQ_PAS_A-
     * @apiVersion 1.0.0
     * @apiParam   {String}         itmid              【必须】暂无注释
     * @apiParam   {Integer}        smcl               【必须】暂无注释
     * @apiParam   {String}         stncd              【必须】暂无注释
     * @apiParam   {String}         wqg                【必须】暂无注释
     * @apiParam   {Double}         wqgulv             暂无注释
     * @apiParam   {Double}         wqgllv             暂无注释
     * @apiSuccess {Integer}        status             1:新增成功;0:新增失败.
     * @apiSuccess {String}         message            成功/失败消息内容
     * @apiSuccess {Object}         data               额外返回的数据,通常包含新增数据的主键值
     * @apiSampleRequest wq/pas/a/insertBatch
     * @apiSuccessExample 新增成功:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":1,
     * "message":"成功",
     * "data":{
     *   "itmid": "TP",
     *   "stncd": "e8c7392e8b984189a89ab594bb3d3e51",
     *   "wqg": "4",
     *   "smcl": 1
     *      }
     *   }
     * }
     @apiSuccessExample 新增失败:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":0,
     * "message":"失败",
     * "data":{
     *   "itmid": "TP",
     *   "stncd": "e8c7392e8b984189a89ab594bb3d3e51",
     *   "wqg": "4",
     *   "smcl": 1
     *      }
     *   }
     * }
     * @apiParamExample {json} 请求示例:
     * [{
     * "itmid": "TP",
     * "smcl": 1,
     * "stncd": "e8c7392e8b984189a89ab594bb3d3e51",
     * "wqg": "4",
     * "wqgulv": 0.3,
     * "wqgllv": 0.2
     * }]
     * @apiUse exceptions
     */
    @POST
    @Path("insertBatch")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response insertBatch(List<WqPasA> recordList) {
        LOGGER.info("批量新增 ,参数 WqPasA:[]", recordList);
        return Response.ok(ApiResultBuilder.create(this, StatusRespBuilder.insert(wqPasAService.insertBatch(recordList),recordList))).build();
    }

    /**
     * @api {put} wq/pas/a/{itmid}/{stncd}/{wqg}/{smcl}/update [U][G]根据主键修改
     * @apiPrivate
     * @apiDescription [G]根据主键修改WQ_PAS_A()数据
     * @apiName (generate)update data
     * @apiGroup WQ_PAS_A-
     * @apiVersion 1.0.0
     * @apiParam   {String}         itmid              【必须】暂无注释
     * @apiParam   {Integer}        smcl               【必须】暂无注释
     * @apiParam   {String}         stncd              【必须】暂无注释
     * @apiParam   {String}         wqg                【必须】暂无注释
     * @apiParam   {Double}         wqgulv             暂无注释
     * @apiParam   {Double}         wqgllv             暂无注释
     * @apiSuccess {Integer}        status             1:修改成功;0:要修改的数据不存在(可能已被删除)
     * @apiSuccess {String}         message            成功/失败消息内容
     * @apiSuccess {Object}         data               额外返回的数据
     * @apiSampleRequest wq/pas/a/TP/e8c7392e8b984189a89ab594bb3d3e51/4/1/update
     * @apiSuccessExample 修改成功:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":1,
     * "message":"成功",
     * "data":null
     *   }
     * }
     * @apiSuccessExample 修改失败:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":0,
     * "message":"失败",
     * "data":null
     *   }
     * }
     * @apiParamExample {json} 请求示例:
     * {
     * "itmid": "TP",
     * "smcl": 1,
     * "stncd": "e8c7392e8b984189a89ab594bb3d3e51",
     * "wqg": "4",
     * "wqgulv": 0.3,
     * "wqgllv": 0.2
     * }
     * @apiUse exceptions
     */
    @PUT
    @Path("{itmid}/{stncd}/{wqg}/{smcl}/update")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response update(@PathParam("itmid") String itmid,@PathParam("stncd") String stncd,@PathParam("wqg") String wqg,@PathParam("smcl") Integer smcl, WqPasA record) {
        record.setItmid(itmid);
        record.setStncd(stncd);
        record.setWqg(wqg);
        record.setSmcl(smcl);
        LOGGER.info("根据主键修改 ,参数 WqPasA:{}", record);
        return Response.ok(ApiResultBuilder.create(this, StatusRespBuilder.update(wqPasAService.updateByPrimaryKey(record)))).build();
    }

    /**
     * @api {put} wq/pas/a/{itmid}/{stncd}/{wqg}/{smcl}/update-selective [U][G]根据主键修改(只修改非null字段)
     * @apiPrivate
     * @apiDescription [G]根据主键修改WQ_PAS_A()数据,只修改非null字段
     * @apiName (generate)update selected data
     * @apiGroup WQ_PAS_A-
     * @apiVersion 1.0.0
     * @apiParam   {String}         itmid              暂无注释
     * @apiParam   {Integer}        smcl               暂无注释
     * @apiParam   {String}         stncd              暂无注释
     * @apiParam   {String}         wqg                暂无注释
     * @apiParam   {Double}         wqgulv             暂无注释
     * @apiParam   {Double}         wqgllv             暂无注释
     * @apiSuccess {Integer}        status             1:修改成功;0:要修改的数据不存在(可能已被删除)
     * @apiSuccess {String}         message            成功/失败消息内容
     * @apiSuccess {Object}         data               额外返回的数据
     * @apiSampleRequest wq/pas/a/TP/e8c7392e8b984189a89ab594bb3d3e51/4/1/update-selective
     * * @apiSuccessExample 修改成功:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":1,
     * "message":"成功",
     * "data":null
     *   }
     * }
     * @apiSuccessExample 修改失败:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":0,
     * "message":"失败",
     * "data":null
     *   }
     * }
     * @apiParamExample {json} 请求示例:
     * {
     * "itmid": "TP",
     * "smcl": 1,
     * "stncd": "e8c7392e8b984189a89ab594bb3d3e51",
     * "wqg": "4",
     * "wqgulv": 0.3,
     * "wqgllv": 0.2
     * }
     * @apiUse exceptions
     */
    @PUT
    @Path("{itmid}/{stncd}/{wqg}/{smcl}/update-selective")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response updateSelective(@PathParam("itmid") String itmid,@PathParam("stncd") String stncd,@PathParam("wqg") String wqg,@PathParam("smcl") Integer smcl, WqPasA record) {
        record.setItmid(itmid);
        record.setStncd(stncd);
        record.setWqg(wqg);
        record.setSmcl(smcl);
        LOGGER.info("根据主键修改(只修改非null字段) ,参数 WqPasA:{}", record);
        return Response.ok(ApiResultBuilder.create(this, StatusRespBuilder.update(wqPasAService.updateByPrimaryKeySelective(record)))).build();
    }

    /**
     * @api {post} wq/pas/a/updateBatch [U][G]根据主键批量修改(只修改非null字段)
     * @apiPrivate
     * @apiDescription [G]根据批量主键修改WQ_PAS_A()数据,只修改非null字段
     * @apiName (generate)updateBatch selected data
     * @apiGroup WQ_PAS_A-
     * @apiVersion 1.0.0
     * @apiParam   {String}         itmid              暂无注释
     * @apiParam   {Integer}        smcl               暂无注释
     * @apiParam   {String}         stncd              暂无注释
     * @apiParam   {String}         wqg                暂无注释
     * @apiParam   {Double}         wqgulv             暂无注释
     * @apiParam   {Double}         wqgllv             暂无注释
     * @apiSuccess {Integer}        status             1:修改成功;0:要修改的数据不存在(可能已被删除)
     * @apiSuccess {String}         message            成功/失败消息内容
     * @apiSuccess {Object}         data               额外返回的数据
     * @apiSampleRequest  wq/pas/a/updateBatch
     * * @apiSuccessExample 修改成功:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":1,
     * "message":"成功",
     * "data":null
     *   }
     * }
     * @apiSuccessExample 修改失败:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":0,
     * "message":"失败",
     * "data":null
     *   }
     * }
     * @apiParamExample {json} 请求示例:
     * [{
     * "itmid": "TP",
     * "smcl": 1,
     * "stncd": "e8c7392e8b984189a89ab594bb3d3e51",
     * "wqg": "4",
     * "wqgulv": 0.3,
     * "wqgllv": 0.2
     * }]
     * @apiUse exceptions
     */
    @POST
    @Path("updateBatch")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response updateBatch(List<WqPasA> record) {
        LOGGER.info("根据主键批量修改(只修改非null字段) ,参数 WqPasA:{}", record);
        return Response.ok(ApiResultBuilder.create(this, StatusRespBuilder.update(wqPasAService.updateBatch(record)))).build();
    }

    /**
     * @api {delete} wq/pas/a/{itmid}/{stncd}/{wqg}/{smcl} [D][G]根据主键删除
     * @apiPrivate
     * @apiDescription [G]根据主键删除WQ_PAS_A()数据
     * @apiName (generate)delete by primary key
     * @apiGroup WQ_PAS_A-
     * @apiVersion 1.0.0
     * @apiSampleRequest wq/pas/a/TP/e8c7392e8b984189a89ab594bb3d3e51/4/1
     * @apiParam   {String}         itmid              【必须】暂无注释
     * @apiParam   {String}         stncd              【必须】暂无注释
     * @apiParam   {String}         wqg                【必须】暂无注释
     * @apiParam   {Integer}        smcl               【必须】暂无注释
     * @apiSuccess {Integer}        status             1:删除成功;0:要删除的数据不存在(可能已被删除).
     * @apiSuccess {String}         message            成功/失败消息内容
     * @apiSuccess {Object}         data               额外返回的数据
     * @apiSuccessExample 删除成功:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":1,
     * "message":"成功",
     * "data":null
     *   }
     * }
     * @apiSuccessExample 删除失败:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":0,
     * "message":"失败",
     * "data":null
     *   }
     * }
     * @apiUse exceptions
     */
    @DELETE
    @Path("{itmid}/{stncd}/{wqg}/{smcl}")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response delete(@PathParam("itmid") String itmid,@PathParam("stncd") String stncd,@PathParam("wqg") String wqg,@PathParam("smcl") Integer smcl) {
         WqPasAKey pk = new WqPasAKey();
        pk.setItmid(itmid);
        pk.setStncd(stncd);
        pk.setWqg(wqg);
        pk.setSmcl(smcl);
        LOGGER.info("根据主键删除 ,参数 pk:{}", pk);
        Integer rows = wqPasAService.deleteByPrimaryKey(pk);
        return Response.ok(ApiResultBuilder.create(this, StatusRespBuilder.delete(rows))).build();
    }

    /**
     * @api {delete} wq/pas/a/by-filter [D][G]根据条件删除
     * @apiPrivate
     * @apiDescription [G]根据条件删除WQ_PAS_A()数据
     * @apiName (generate)delete by filter
     * @apiGroup WQ_PAS_A-
     * @apiVersion 1.0.0
     * @apiSampleRequest wq/pas/a/by-filter
     * @apiParam   {String}         itmid              暂无注释
     * @apiParam   {List(Integer)}  smclList           (数组)暂无注释
     * @apiParam   {String}         stncd              暂无注释
     * @apiParam   {List(String)}   wqgList            (数组)暂无注释
     * @apiParam   {Double}         wqgulvMin          (最小)暂无注释
     * @apiParam   {Double}         wqgulvMax          (最大)暂无注释
     * @apiParam   {Double}         wqgllvMin          (最小)暂无注释
     * @apiParam   {Double}         wqgllvMax          (最大)暂无注释
     * @apiSuccess {Integer}        status             通常1或者>1:删除成功;0:没有符合条件的数据.
     * @apiSuccess {String}         message            成功/失败消息内容
     * @apiSuccess {Object}         data               额外返回的数据
     * @apiSuccessExample 删除成功:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":1,
     * "message":"成功",
     * "data":null
     *   }
     * }
     * @apiSuccessExample 删除失败:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":0,
     * "message":"失败",
     * "data":null
     *   }
     * }
     * @apiUse exceptions
     */
    @DELETE
    @Path("by-filter")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response deleteByFilter(WqPasAQo filter) {
        LOGGER.info("根据条件删除 ,参数 WqPasAQo:{}", filter);
        Integer rows = wqPasAService.deleteByFilter(filter);
        return Response.ok(ApiResultBuilder.create(this, StatusRespBuilder.delete(rows))).build();
    }
}
